package com.tiantianyuegou.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.tiantianyuegou.R;

/**
 * Created by Administrator on 2016/1/9.
 */
public class CouponAdapter extends BaseAdapter{

    private Context context;
    private String[] money_num;
    private String[] text_reason;
    private String[] text_name;
    private String[] text_ticket;
    private String[] text_data;
    private LayoutInflater inflater;

    public CouponAdapter(){

    }

    public CouponAdapter(Context context,String[] money_num,String[] text_reason,String[] text_name,String[] text_ticket,String[] text_data){
        this.context=context;
        this.money_num=money_num;
        this.text_reason=text_reason;
        this.text_name=text_name;
        this.text_ticket=text_ticket;
        this.text_data=text_data;
        inflater=LayoutInflater.from(context);
    }
    @Override
    public int getCount() {
        return money_num.length;
    }

    @Override
    public Object getItem(int i) {
        return i;
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        HolderView holder=null;
        if (view==null){
            holder=new HolderView();
            view=inflater.inflate(R.layout.item_list_mycoupon,null);
            holder.text_money_num=(TextView)view.findViewById(R.id.text_money_num);
            holder.text_reason=(TextView)view.findViewById(R.id.text_reason);
            holder.text_name=(TextView)view.findViewById(R.id.text_name);
            holder.text_ticket=(TextView)view.findViewById(R.id.text_ticket);
            holder.text_data=(TextView)view.findViewById(R.id.text_data);
            view.setTag(holder);
        }else{
            holder=(HolderView) view.getTag();
        }

        holder.text_money_num.setText(money_num[i]);
        holder.text_reason.setText(text_reason[i]);
        holder.text_name.setText(text_name[i]);
        holder.text_ticket.setText(text_ticket[i]);
        holder.text_data.setText(text_data[i]);

        return view;
    }

    public static class HolderView{
        TextView text_money_num,text_reason,text_name,text_ticket,text_data;
    }
}
